package com.atguigu.gmall.realtime.web.service.impl;

import com.atguigu.gmall.realtime.web.bean.NameValueBean;
import com.atguigu.gmall.realtime.web.mapper.TradeProvinceOrderWindowMapper;
import com.atguigu.gmall.realtime.web.service.TradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class TradeServiceImpl implements TradeService {

    @Autowired
    TradeProvinceOrderWindowMapper tradeProvinceOrderWindowMapper;

    @Override
    public BigDecimal getTotalAmount(String date) {
        Long dt = Long.valueOf(date.replace("-", ""));

        BigDecimal totalAmount = tradeProvinceOrderWindowMapper.getTotalAmount(dt);
        return totalAmount;
    }

    @Override
    public List<NameValueBean> getOrderAmountByProvince(String date) {
        Long dt = Long.valueOf(date.replace("-", ""));
        List<NameValueBean> nameValueBeanList = tradeProvinceOrderWindowMapper.getOrderAmountGroupByProvince(dt);

        return nameValueBeanList;
    }
}
